const mysql=require('mysql');
const poolConf={
  host:'localhost',
  database:'sequelize',
  user:'root',
  password:'mWXS19971222@.',
  port:3306
}
const dbPool={
  pool:{},
  create(){
    this.pool=mysql.createPool(poolConf)
  },
  close(){
    this.pool.end();
  },
  connect(sql,arr,fun){
    this.pool.getConnection(function (err,connection) {//err获取连接对象的错误信息
      //操作数据库
      connection.query(sql,arr,fun)//这个err代表操作数据库的错误信息
      connection.release();
    });
  }
}
dbPool.create()//在引入文件时,就创建了,一旦创建this就指向dbPool
module.exports= dbPool
